package com.lanju.dao;

import java.util.Date;
import java.util.Map;
import java.util.UUID;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import com.lanju.entity.Recom;
import com.lanju.entity.Suggest;


@Repository
public class SuggestDao extends BaseDao<Recom,String>{
    
    private static final Log log = LogFactory.getLog(SuggestDao.class);
    @Autowired
   	SessionFactory sessionFactory;
    
    @PersistenceContext(unitName = "financialmarketingUnit")
    private EntityManager entityManager;

    @SuppressWarnings("unchecked")
	public void insertSuggest(Map<String, Object> param) {
    	Suggest s = new Suggest();
    	s.setSuggestId(UUID.randomUUID().toString());
		 if(!StringUtils.isEmpty(param.get("userId"))) {
			 s.setUserId(param.get("userId").toString());
		   }
		 if(!StringUtils.isEmpty(param.get("content"))) {
			 s.setContent(param.get("content").toString());
		   }
		 if(!StringUtils.isEmpty(param.get("type"))) {
			 s.setType(param.get("type").toString());
		   }
		 if(!StringUtils.isEmpty(param.get("userName"))) {
			s.setUserName(param.get("userName").toString());
		   }
		 if(!StringUtils.isEmpty(param.get("status"))) {
			 s.setStatus(Integer.valueOf(param.get("status").toString()));
		   }
		 if(!StringUtils.isEmpty(param.get("phone"))) {
			s.setPhone(param.get("phone").toString());
		   }
		 s.setCreateTime(new Date());
		 entityManager.persist(s);
	}
    
}
